-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to set a custom mask interpolation method #945
base: main
Are you sure you want to change the base?
Conversation
Or as an alternative for Option 2, maybe it is better to an explicit argument for all
What do you think? |
if mask_interpolation not in { | ||
cv2.INTER_NEAREST, | ||
cv2.INTER_NEAREST_EXACT, | ||
cv2.INTER_LINEAR, | ||
cv2.INTER_LINEAR_EXACT, | ||
cv2.INTER_AREA, | ||
cv2.INTER_CUBIC, | ||
cv2.INTER_LANCZOS4, | ||
cv2.INTER_MAX, | ||
}: | ||
raise ValueError( | ||
f"Value {mask_interpolation} is not supported. " | ||
f"Choose one of the following methods: cv2.INTER_NEAREST, cv2.INTER_NEAREST_EXACT, cv2.INTER_LINEAR, " | ||
f"cv2.INTER_LINEAR_EXACT, cv2.INTER_AREA, cv2.INTER_CUBIC, cv2.INTER_LANCZOS4, cv2.INTER_MAX" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better to create an Enum as class field for this flag?
With Enum error message would be much more clearly.
for t in self.transforms: | ||
if isinstance(t, BaseCompose) or (isinstance(t, DualTransform) and t.mask_interpolation is None): | ||
t.set_mask_interpolation(mask_interpolation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange condition, I am not sure that it will be work correctly, because mask_interpolation
has no default value.
I think approach better, but it is need to change |
please |
@LucaBonfiglioli Will look into this. |
Heavy +1 for this PR. It's been 3 years since discussion and PR looks almost done. What's needed to finalise it? @ternaus @Dipet The problems with resizing are very difficult to debug and lead to worse model performance. I had bad experience using Albumentations for segmentations and super resolutions tasks due to that and avoid using most of "geometrical" transformations for the same reason. |
We can do it. As I understand, you are "Power User", meaning use the library for your task + use advanced features. Sent you invitation to connect on LInkedIn, let's have video chat, your feedback / requests will help with the prioritization. |
This is POC to fix an issue in #850. It supports two styles for setting mask interpolation.
Option 1. Set a global value for mask interpolation through
Compose
:Option 2. Override a value for mask interpolation for a single transform: